﻿using HttpApiGateway.Interface;
using RpcClient.Interface;

namespace HttpApiGateway.Idempotent
{
    [RpcClient.Attr.ClassLifetimeAttr(RpcClient.Attr.ClassLifetimeType.单例)]
    internal class TokenIdempotent : ITokenIdempotent
    {
        private ITokenIdempotent _Service;

        public TokenIdempotent(IIdempotentConfig config,IUnityCollect unity)
        {
            _Service = unity.Resolve<ITokenIdempotent>(config.SaveType.ToString());
        }

        public StatusSaveType SaveType => _Service.SaveType;

        public string ApplyToken()
        {
            return _Service.ApplyToken();
        }

        public void Dispose()
        {
            _Service.Dispose();
        }

        public bool SubmitToken(string tokenId)
        {
            return _Service.SubmitToken(tokenId);
        }
    }
}
